def convert(s, numRows):
    if numRows < 2: return s
    res = ["" for _ in range(numRows)]
    i, flag = 0, -1
    for c in s:
        res[i] += c
        if i == 0 or i == numRows - 1: flag = -flag
        i += flag
    return "".join(res)

text = input().split(" ")
s = text[0]
numRows = int(text[1])
print(convert(s, numRows))